function hrefBack() {
    history.go(-1);
}

function decodeQuery(){
    var search = decodeURI(document.location.search);
    return search.replace(/(^\?)/, '').split('&').reduce(function(result, item){
        values = item.split('=');
        result[values[0]] = values[1];
        return result;
    }, {});
}

$(document).ready(function(){

    $(".book-house").show();
    //获取参数
    var queryData = decodeQuery();
    var house_id = queryData['id'];
    //获取详情信息
    $.get('/api/houses/' + house_id,function (xhr) {
        house_info = JSON.parse(xhr.data.info);
        console.log(house_info);
        //详情信息
        $('.detail-con').html(template('house_detail_tpl', {house: house_info}));
        //图片
        $('.swiper-container').html(template('house_image_tpl', {images: house_info.img_urls, price: house_info.price}));
        //房屋图片轮播
        var mySwiper = new Swiper ('.swiper-container', {
            loop: true,
            autoplay: 2000,
            autoplayDisableOnInteraction: false,
            pagination: '.swiper-pagination',
            paginationType: 'fraction'
        })
        // xhr.uid为访问页面用户,xhr.data.user_id为房东
       // if (xhr.data.uid != xhr.data.info.uid) {
            $(".book-house").attr("href", "/booking.html?hid="+house_id);
            $(".book-house").show();
       // }
    })
})